package com.longteng.lesson2.thread;

import java.util.concurrent.*;

/**
 * Created by li
 * DATE : 2018/11/25 0025
 * TIME : 22:58
 * PROJECT : java-lesson
 * PACKAGE : com.longteng.lesson
 *
 * @author <a href="mailto:55324936@qq.com">li</a>
 */
public class ThreadPool {
    public static void main(String[] args) {
        int corePoolSize =10;
        int maxPoolSize =15;
        ExecutorService executorService= new ThreadPoolExecutor(corePoolSize, maxPoolSize,
                0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>());
//        ExecutorService executorService= Executors.newFixedThreadPool(10);
        MyRunnable myRunnable=new MyRunnable();
        for(int i=0;i<20;i++) {
            executorService.execute(myRunnable);
        }
        executorService.shutdown(); //关闭线程池
        System.out.println("主线程");
    }
}
